#include "stdafx.hpp"
#include "ColligereDatabaseError.hpp"

col::DatabaseError::DatabaseError ( const wxString &rErrMsg, 
								   const wxString &rFile, 
								   const wxString &rQuery ) 
								   : mErrMsg ( rErrMsg ), mFile ( rFile ), 
								   mQuery ( rQuery ) 
{
}

col::DatabaseError::~DatabaseError() throw()
{
}

const wxString &col::DatabaseError::GetMessage() const 
{ 
	return mErrMsg; 
}

const wxString &col::DatabaseError::GetQuery() const 
{ 
	return mQuery; 
}

const wxString &col::DatabaseError::GetFile() const 
{ 
	return mFile; 
}

const char *col::DatabaseError::what() const throw()
{
	static wxString msg;

	msg = boost::str ( boost::format ( _("Database Error: %1%\n\nFile: %2%\n\nQuery: "\
		"%3%") ) % mErrMsg % mFile % ( mQuery.empty() ?  _("N/A") : mQuery ) );

	return msg.c_str();
}